<!DOCTYPE html>
<html>
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
  <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" /> 
  <link rel="shortcut icon" href="https://exp-blog.com/favicon.png" /> 
  <meta name="author" content="EXP: www.exp-blog.com" /> 
  <title>眈眈探求 | 任意文本转HTML-UNICODE</title> 
  <meta name="keywords" content="任意文本转HTML-UNICODE" /> 
  <link rel="stylesheet" type="text/css" href="../../base/css/bootstrap.min.css" /> 
  <link rel="stylesheet" type="text/css" href="../../base/css/font-awesome.css" /> 
  <script type="text/javascript" src="../../base/js/jquery.min.js"></script> 
  <script type="text/javascript" src="../../base/js/clipboard.min.js"></script> 
  <script type="text/javascript" src="../../base/js/bootstrap.min.js"></script> 
  <script type="text/javascript" src="../../base/css/layer/layer.js"></script> 
  <script type="text/javascript" src="../../base/js/main.js"></script> 
  <link rel="stylesheet" type="text/css" href="../../base/css/base.css" /> 
 </head> 
 <body> 
  <div class="container clearfix"> 
   <div class="panel panel-default"> 
    <div class="panel-heading">
      工具简介 
    </div> 
    <div class="panel-body"> 
     <p>有时HTML在存储时只能使用ISO-8859-1编码，但又要显示中文、表情等非ASCII的特殊字符。 <br />此时可以使用此工具把这类字符转码成UNICODE，浏览器在呈现时会显示为原本字符。</p> 
    </div> 
   </div> 
   <div class="panel panel-default"> 
    <div class="panel-heading"> 
     <h3 class="panel-title">任意文本转HTML-UNICODE</h3> 
    </div> 
    <div class="panel-body"> 
     <div class="col-md-6 col-md-offset-3"> 
      <form role="form" onsubmit="return false;"> 
       <div class="form-group"> 
        <textarea class="form-control" rows="3" id="html_content" placeholder="输入文本"></textarea> 
       </div> 
       <div class="form-group"> 
        <button type="submit" class="btn btn-default btn-lg btn-block" onclick="return toUnicode();">转换</button> 
       </div> 
      </form> 
      <div class="form-group"> 
       <div class="alert alert-success" role="alert" id="unicode_text" style="word-wrap : break-word ;">
        请输入文本进行转换
       </div> 
      </div> 
     </div> 
    </div> 
   </div> 
  </div> 
  <script>
	  function toUnicode(){

	    var s = document.getElementById('html_content').value;
	    var as = "";
	    for(var a = 0; a<s.length; a++){
	      as += "&amp;#"+s.charCodeAt(a)+";";
	    }
	    document.getElementById('unicode_text').innerHTML = '' + as;
	    return false;
	  }
	</script>  
 </body>
</html>